package com.hello.factory;

/**
 * 工厂模式
 */
public class Factory {

    public static Fruit getInstance(String className) {
        Fruit f= null;
        try {
            // 反射获取对象实例
            f = (Fruit) Class.forName(className).newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return f;
    }

}
